//封装和文章相关的接口函数
import { request } from "@/utils";

//1.获取频道列表
function getChannelApi(loginForm){
    return request({
         url:'/channels',
         method:"GET"
     })
 }

 //新增文章接口
 function createArticleAPI(values){
    return request({
         url:'/mp/articles?draft=false',
         method:"POST",
         data:values
     })
 }

 //获取文章列表
 function getArticleListAPI(params){
    return request({
         url:'/mp/articles',
         method:"GET",
         params
     })
 }

 //删除文章列表
 function deleteArticleAPI(id){
    return request({
         url:`/mp/articles/${id}`,
         method:"DELETE"
     })
 }

 //获取文章详情
 function getArticleById(id){
    return request({
         url:`/mp/articles/${id}`,
         method:"GET"
     })
 }

 //更新文章
 function updateArticleById(data){
    return request({
         url:`/mp/articles/${data.id}?draft=false`,
         method:"PUT",
         data
     })
 }

 export {
    getChannelApi,
    createArticleAPI,
    getArticleListAPI,
    deleteArticleAPI,
    getArticleById,
    updateArticleById
 }